import api from '../../../api/index';
// import util from '../../../utils/util'
// import mszUtil from '../../utils/util.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    exam_id: null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var id = options.exam_id
    this.setData({
      exam_id: id
  })
  this.getReportDetail(id)
  },

  /**
     * 根据id 获取报告详情
     */
    getReportDetail(id) {
      var that = this
      wx.showLoading({
          title: '加载中',
      })
      api.get(`/api/exams/record/${id}`, {
          head: {
              "firstresult": 0,
              "maxresults": 10000,
              "bodytype": "flat"
          },
          data: {}
      }).then(res => {
          wx.hideLoading()
          if (res.length > 0) {
              that.initReportData(res[0])
          }
          console.log("res-->", res)
      }).catch(err => {
          wx.hideLoading()
          console.log("err-->", err)
      })
  },
  initReportData(object) {
    console.log(object);
    var that = this
    var fraction = ''
    var zhengzhuan = ''
    var bagangtu = ''
    var zhuangjiaContent = ''
    var healthLists = []
    let summary = null
    if(object.summary) {
      summary = JSON.parse(object.summary)
    }
    console.log(summary);
    // var evaluation = object.exam_evaluation
    // fraction = evaluation.substring(evaluation.indexOf("得分") + 3, evaluation.indexOf("，"))
    // if (isNaN(fraction) || !fraction) {
    //     fraction = ''
    // } else {
    //     fraction = parseFloat(fraction)
    // }

    // var objArr = JSON.parse(object.exam_summary)
    // console.log(objArr);
    // console.log(objArr);
    // if (objArr) {
    //     console.log(objArr.opinion);
    //     zhuangjiaContent = objArr.opinion
    //     zhengzhuan = objArr.diseaseName
    // }
    // if (object.exam_conclusion) {
    //     var conclusionArr = object.exam_conclusion.split(':')
    //     if (conclusionArr.length > 1) {
    //         var healthObject = new Object()
    //         healthObject.name = conclusionArr[0]
    //         healthObject.content = conclusionArr[1]
    //         healthLists[0] = healthObject
    //     }
    // }
    // console.log(object.devices);
    // that.initIndexList(object.devices)
    // var zhengobj = new Object()
    // zhengobj.zhengzhuang = zhengzhuan
    // zhengobj.socre = fraction
    // that.setData({
    //     zhengzhuang: zhengzhuan,
    //     zhengzhuangScore: fraction,
    //     expertReviewsContent: zhuangjiaContent,
    //     healthList: healthLists,
    //     bagangtu: bagangtu,
    //     exam_uuid: object.exam_uuid,
    //     zhengZhuangObj: zhengobj
    // })
},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})